package
{
	import flash.display.Sprite;
	import flash.filesystem.File;
	import flash.filesystem.FileMode;
	import flash.filesystem.FileStream;
	import flash.utils.ByteArray;

	public class EverydayStage3D5 extends Sprite
	{
		public function EverydayStage3D5()
		{
			createVertextData();
			createIndexData();
			createFAGAL();
			createVAGAL();
		}

		private function createVertextData():void
		{
			//三角形顶点数据
			var triangleData:Vector.<Number> = Vector.<Number>([
				//  x, y, r, g, b
				0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0]);
			var byte:ByteArray = VertexData.createVertextData(triangleData, 5);
			 var file:File =new File(File.applicationDirectory.resolvePath("ver.stage3dvertex").nativePath);
			var fileStream:FileStream = new FileStream();
			fileStream.open(file, FileMode.UPDATE);
			fileStream.writeBytes(byte);
			fileStream.close();
		}

		private function createIndexData():void
		{
			//三角形索引数据
			var indexData:Vector.<uint> = Vector.<uint>([0, 1, 2]);
			var byte:ByteArray = VertexData.createIndexData(indexData);
			var file:File = new File(File.applicationDirectory.resolvePath("ver.stage3dindex").nativePath);
			var fileStream:FileStream = new FileStream();
			fileStream.open(file, FileMode.UPDATE);
			fileStream.writeBytes(byte);
			fileStream.close();
		}

		private function createFAGAL():void
		{
			//片段渲染程序
			var byte:ByteArray = VertexData.createFAGAL("mov oc, v0");
			var file:File = new File(File.applicationDirectory.resolvePath("ver.stage3dfagaL").nativePath);
			var fileStream:FileStream = new FileStream();
			fileStream.open(file, FileMode.UPDATE);
			fileStream.writeBytes(byte);
			fileStream.close();
		}

		private function createVAGAL():void
		{
			//片段渲染程序
			var byte:ByteArray = VertexData.createVAGAL("mov op, va0\n" + "mov v0, va1");
			var file:File = new File(File.applicationDirectory.resolvePath("ver.stage3dvagal").nativePath);
			var fileStream:FileStream = new FileStream();
			fileStream.open(file, FileMode.UPDATE);
			fileStream.writeBytes(byte);
			fileStream.close();
		}

	}
}
